<html>
<head>
<title>a</title>
<?php
$pages = (isset($pages))?(($pages=='')?1:$pages):1;
$page = (isset($page))?(($page=='')?1:$page):1;
$ppline = (isset($ppline))?(($ppline=='')?15:$ppline):15;
$lines = ceil($pages/$ppline);

/*
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
*/
function GenerarURL($dato=''){
	/*
	if(count($_SERVER['argv'][0]) > 0){
		$variables = explode('&', $_SERVER['argv'][0]);
	}*/
	// if(count($_SERVER['REQUEST_URI']) > 0){
		// $variables = explode('&', $_SERVER['REQUEST_URI']);
	// }
	//echo "dato:".$dato;
	/*$variables[] = $dato;
	foreach($variables as $key => $val){
		$xxx = explode('=', $val);
		$nuevas[$xxx[0]] = $xxx[1];
	}
	$cadena = '';
	foreach($nuevas as $key => $val){
		$cadena .= ($cadena == '')? ('?'.$key.'='.$val):('&'.$key.'='.$val);
	}*/
	
	return $dato;
}
?>
<style>
.flechas{
	font-family:Arial, Verdana, Tahoma;
	font-size:12px;
	font-weight:bold;
}
.paginas{
	font-family:Arial, Verdana, Tahoma;
	font-size:11px;
}
.seleccionado{
	font-family:Arial, Verdana, Tahoma;
	font-size:16px;
	font-weight:bold;
}
</style>
</head>
<body>
<table align="center" border="0" cellpadding="0" cellspacing="0">
	<tr>
        <td width="20" align="center" valign="middle" class="flechas"><?php echo ($page != 1)? '<a href="'.GenerarURL($datosToPagePagin.'&page=1').'">&lt;&lt;</a>': '&lt;&lt;'?></td>
        <td width="20" align="center" valign="middle" class="flechas"><?php echo ($page != 1)? '<a href="'.GenerarURL($datosToPagePagin.'&page='.($page - 1)).'">&lt;</a>': '&lt;'?></td>
      	<td>
        	<?php
			for($j = 1; $j <= $lines; $j++){
			?>
        	<table align="center" border="0" cellpadding="0" cellspacing="0">
            	<tr>
				<?php
                for($i = 1; (($i + ($ppline * ($j - 1))) <= ($ppline * $j) && (($i + ($ppline * ($j - 1))) <= $pages)); $i++){
                ?>
                	<td width="20" align="center" valign="middle" class="<?php echo ($page == ($i + (($j-1)*$ppline)))?'seleccionado':'paginas';?>"><?php echo ($page != ($i+(($j-1)*$ppline)))? '<a href="'.GenerarURL($datosToPagePagin.'&page='.($i+(($j-1)*$ppline))).'">'.($i+(($j-1)*$ppline)).'</a>':($i+(($j-1)*$ppline));?></td>
				<?php
                    }
                ?>
                </tr>
            </table>
            <?php
			}
			?>
        </td>
        <td width="20" align="center" valign="middle" class="flechas"><?php echo ($page != $pages)? '<a href="'.GenerarURL($datosToPagePagin.'&page='.($page + 1)).'">&gt;</a>': '&gt;'?></td>
      	<td width="20" align="center" valign="middle" class="flechas"><?php echo ($page != $pages)? '<a href="'.GenerarURL($datosToPagePagin.'&page='.$pages).'">&gt;&gt;</a>': '&gt;&gt;'?></td>
  	</tr>
</table>
</body>
</html>
